using System.ComponentModel.DataAnnotations;
using GroupSix.Domain.common;

namespace GroupSix.Application.Dtos;

/// <summary>
/// 创建菜单请求DTO
/// </summary>
public class CreateMenuRequestDto
{
    /// <summary>
    /// 菜单名称
    /// </summary>
    [Required(ErrorMessage = "菜单名称不能为空")]
    [StringLength(50, ErrorMessage = "菜单名称长度不能超过50个字符")]
    public string Menuname { get; set; } = null!;

    /// <summary>
    /// 菜单路径
    /// </summary>
    [StringLength(200, ErrorMessage = "菜单路径长度不能超过200个字符")]
    public string? MenuPath { get; set; }

    /// <summary>
    /// 菜单图标
    /// </summary>
    [StringLength(100, ErrorMessage = "菜单图标长度不能超过100个字符")]
    public string? MenuIcon { get; set; }

    /// <summary>
    /// 父菜单ID
    /// </summary>
    public Guid? ParentId { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    [Range(0, 9999, ErrorMessage = "排序值必须在0-9999之间")]
    public int Order { get; set; } = 0;

    /// <summary>
    /// 权限标识
    /// </summary>
    [StringLength(100, ErrorMessage = "权限标识长度不能超过100个字符")]
    public string? PermissionKey { get; set; }
}

/// <summary>
/// 更新菜单请求DTO
/// </summary>
public class UpdateMenuRequestDto
{
    /// <summary>
    /// 菜单ID
    /// </summary>
    [Required(ErrorMessage = "菜单ID不能为空")]
    public Guid Id { get; set; }

    /// <summary>
    /// 菜单名称
    /// </summary>
    [Required(ErrorMessage = "菜单名称不能为空")]
    [StringLength(50, ErrorMessage = "菜单名称长度不能超过50个字符")]
    public string Menuname { get; set; } = null!;

    /// <summary>
    /// 菜单路径
    /// </summary>
    [StringLength(200, ErrorMessage = "菜单路径长度不能超过200个字符")]
    public string? MenuPath { get; set; }

    /// <summary>
    /// 菜单图标
    /// </summary>
    [StringLength(100, ErrorMessage = "菜单图标长度不能超过100个字符")]
    public string? MenuIcon { get; set; }

    /// <summary>
    /// 父菜单ID
    /// </summary>
    public Guid? ParentId { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    [Range(0, 9999, ErrorMessage = "排序值必须在0-9999之间")]
    public int Order { get; set; } = 0;

    /// <summary>
    /// 权限标识
    /// </summary>
    [StringLength(100, ErrorMessage = "权限标识长度不能超过100个字符")]
    public string? PermissionKey { get; set; }
}

/// <summary>
/// 获取菜单列表请求DTO
/// </summary>
public class GetMenusRequestDto : PageRequest
{
    /// <summary>
    /// 菜单名称（搜索）
    /// </summary>
    public string? Menuname { get; set; }

    /// <summary>
    /// 菜单路径（搜索）
    /// </summary>
    public string? MenuPath { get; set; }

    /// <summary>
    /// 父菜单ID（筛选）
    /// </summary>
    public Guid? ParentId { get; set; }
}

/// <summary>
/// 菜单响应DTO
/// </summary>
public class MenuResponseDto
{
    /// <summary>
    /// 菜单ID
    /// </summary>
    public Guid Id { get; set; }

    /// <summary>
    /// 菜单名称
    /// </summary>
    public string Menuname { get; set; } = null!;

    /// <summary>
    /// 菜单路径
    /// </summary>
    public string? MenuPath { get; set; }

    /// <summary>
    /// 菜单图标
    /// </summary>
    public string? MenuIcon { get; set; }

    /// <summary>
    /// 父菜单ID
    /// </summary>
    public Guid? ParentId { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    public int Order { get; set; }

    /// <summary>
    /// 权限标识
    /// </summary>
    public string? PermissionKey { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreatedAt { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime UpdatedAt { get; set; }

    /// <summary>
    /// 子菜单列表
    /// </summary>
    public List<MenuResponseDto> Children { get; set; } = new List<MenuResponseDto>();
}

/// <summary>
/// 菜单树节点DTO
/// </summary>
public class MenuTreeNodeDto
{
    /// <summary>
    /// 菜单ID
    /// </summary>
    public Guid Id { get; set; }

    /// <summary>
    /// 菜单名称
    /// </summary>
    public string Menuname { get; set; } = null!;

    /// <summary>
    /// 菜单路径
    /// </summary>
    public string? MenuPath { get; set; }

    /// <summary>
    /// 菜单图标
    /// </summary>
    public string? MenuIcon { get; set; }

    /// <summary>
    /// 父菜单ID
    /// </summary>
    public Guid? ParentId { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    public int Order { get; set; }

    /// <summary>
    /// 权限标识
    /// </summary>
    public string? PermissionKey { get; set; }

    /// <summary>
    /// 子菜单列表
    /// </summary>
    public List<MenuTreeNodeDto> Children { get; set; } = new List<MenuTreeNodeDto>();
}

/// <summary>
/// 菜单列表响应DTO
/// </summary>
public class MenuListResponseDto
{
    /// <summary>
    /// 菜单树列表
    /// </summary>
    public List<MenuTreeNodeDto> MenuTree { get; set; } = new List<MenuTreeNodeDto>();

    /// <summary>
    /// 总数
    /// </summary>
    public int TotalCount { get; set; }
}

/// <summary>
/// 调整菜单顺序请求DTO
/// </summary>
public class UpdateMenuOrderRequestDto
{
    /// <summary>
    /// 菜单ID
    /// </summary>
    [Required(ErrorMessage = "菜单ID不能为空")]
    public Guid Id { get; set; }

    /// <summary>
    /// 新排序值
    /// </summary>
    [Range(0, 9999, ErrorMessage = "排序值必须在0-9999之间")]
    public int Order { get; set; }
} 